﻿using STHPMS1.DAL.D_Core;
using System.Data;
using ServiceStack.OrmLite;
using STHPMS1.ICore.I_Entity.Stmpms1;
using STHPMS1.Common.C_Entity.Stmpms1;
using STHPMS1.ICore.I_DAL.Repository;
using System.Collections.Generic;
using System.Data.SqlClient;

namespace STHPMS1.DAL.D_Repository
{
    public class Df_Funlim_ProjRepository : DalBase, IDf_Funlim_ProjRepository
    {
        /// <summary>
        /// 获取资金受限条件养护方案表符合条件的一条数据
        /// </summary>
        /// <param name="anniname">资金模型名称</param>
        /// <param name="rd_class">技术等级</param>
        /// <param name="pci">PCI值</param>
        /// <param name="pqi">PQI值</param>
        /// <returns></returns>
        public IDf_Funlim_Proj GetDf_Funlim_Proj(string anniname,string Analy_Year, int rd_class, int pci)
        {
            IDbConnection conn = Adapter.OpenDbConnection();
            string strsql = "select top 1 * from DF_FUNLIM_PROJ where ANNI_NAME='" + anniname + "' and ANALY_YEAR='" + Analy_Year + "' and RD_CLASS=" + rd_class + "  and PCI<=" + pci + " and ORDERNUM is null order by PCI asc,PQI asc";
            return conn.Single<Df_Funlim_Proj>(strsql);
           
        }


        /// <summary>
        /// 获取规划年度养护需求分析信息
        /// </summary>
        /// <param name="divi_time">规划年度</param>
        /// <param name="mainsegid">决策路段</param>
        /// <returns></returns>
        public IDn_Divi_Planning GetDn_Divi_Planning(string anniname,string divi_time, string mainsegid)
        {
            IDbConnection conn = Adapter.OpenDbConnection();
            string strsql = "select * from DN_DIVI_PLANNING where ANNI_NAME='" + anniname + "'  and DIVI_TIME='" + divi_time + "' and MAINSEGID='" + mainsegid + "'";
            return conn.Single<Dn_Divi_Planning>(strsql);
           
        }
    }
}
